import requests


def request(url, headers, method="get", **kwargs):
    # 获取保存的token,添加到请求头即可
    # if(headers){
    #     headers = headers.update({
    #     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
    # })
    # }

    headers = headers.update({
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36',
    })
    res=requests.request(method, url, headers=headers, timeout=10000, **kwargs).json()
    
    match res["state"]:
        case 200:
            pass
            # tkinter.messagebox.showinfo(title="提示",message="登录成功")
            # f = open('localStorage.json','w', encoding='utf-8')
            # f.write(json.dumps(cookie["data"], indent=4))
            # f.close()
            # Interface.login.destroy()
        case _:
            pass
            # tkinter.messagebox.showerror(title="错误", message=cookie["message"])
    return res
